﻿
namespace SvGame.Objects;

[Desc("装备")]
public partial class Equip
{
    #region 存档

    [Desc("UID")]
    public long Uid = 0;
    [Desc("ID")]
    public int ConfigId = 0;

    [Desc("属性")]
    public Dictionary<int, int> DictProp = new();

    #endregion


    #region 不存档 //[JsonIgnore]

    [Desc("临时属性")]
    [JsonIgnore]
    public Dictionary<int, int> DictTemp = new();

    [Desc("环境")]
    [JsonIgnore]
    public object Env = null;
    public bool GetEnv(out object env)
    {
        env = Env;
        return (env != null);
    }
    [Desc("配置")]
    [JsonIgnore]
    private ConfigEquip _Cfg = null;
    [JsonIgnore]
    public ConfigEquip Cfg
    {
        get
        {
            if (_Cfg == null)
            {
                if (!ConfEquip.TryGetValue(ConfigId, out _Cfg))
                {
                    loger.Warn($"装备配置错误 ConfigId{ConfigId}");
                    _Cfg = new ConfigEquip();
                }
            }
            return _Cfg;
        }
        set { _Cfg = value; }
    }

    #endregion

    public string DescShort() => $"{ChineseNumber(1)}{Cfg.Unit}{Cfg.Name}";

}
